package com.woniu.service.Impl.backpage;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.dao.backpage.DistributionDao;
import com.woniu.entity.Distribution;
import com.woniu.service.backpage.IDistributionService;
import com.woniu.util.RequestParams;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 凌雨
 * @data 2023/3/14 16:23
 */
@Service
public class DistributionServiceImpl implements IDistributionService {

    @Autowired
    private DistributionDao distributionDao;

    /**
     * 根据条件查询配送详情
     * @param requestParams
     * @return
     */
    @Override
    public ResData<?> queryDistribution(RequestParams<Distribution> requestParams) {
        PageHelper.startPage(requestParams.getPageNo(),requestParams.getPageSize());
        List<Distribution> distributionList = distributionDao.queryAll(requestParams.getParam(),
                requestParams.getData().getState(),
                requestParams.getData().getRegion(),
                requestParams.getData().getStartTime(),
                requestParams.getData().getEndTime());
        PageInfo<Distribution> pageInfo = new PageInfo<>(distributionList);
        return new ResData<>().ok(pageInfo);
    }
}
